<?php
namespace app\house\controller;
use app\AdminRest;
use think\App;
use think\Request;
use app\house\model\AdminPrice as price_model;
class AdminPrice extends AdminRest
{

    protected $model;
    public function __construct(App $app) {
        parent::__construct($app);
        $this->model = new price_model();
    }

    /**
     * 房产价格列表
     */
    public function priceList(){
        $data = $this->model->priceList(['uniacid'=>$this->_uniacid]);
        return $this->success($data);
    }

    /**
     *
     * 添加房产价格
     */
    public function priceAdd(){
        $input = $this->_input;
        if(empty($input['title'])||empty($input['value'])){
            return $this->error('参数不能为空');
        }
        $input['uniacid'] = $this->_uniacid;
        $res = $this->model->priceAdd($input);
        return $this->success($res);
    }

    /**
     *
     * 编辑房产价格
     */
    public function priceUpdate(){
        $input = $this->_input;
        if(count($input)>1){
            if(empty($input['title'])||empty($input['value'])){
                return $this->error('参数不能为空');
            }
            $data = $this->model->priceUpdate(['id'=>$input['id']],$input);
        }else{
            $data = $this->model->priceInfo(['id'=>$input['id']]);
        }
        return $this->success($data);
    }

    /**
     *
     * 删除房产价格
     */

    public function priceDel(){
        $input = $this->_input;
        $res   = $this->model->priceDel(['id'=>$input['id']]);
        return $this->success($res);

    }



}
